#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
void q_sort(vector<int>& hehe, int l, int r)
{
    if (l >= r)
        return;
    int i = l - 1;
    int j = r + 1;
    int x = hehe[l];
    while (i < j)
    {
        do
        {
            i++;
        } while (hehe[i] < x);
        do
        {
            j--;
        } while (hehe[j] > x);
        if (i < j)
        {
            int tem = hehe[i];
            hehe[i] = hehe[j];
            hehe[j] = tem;
        }
    }
    q_sort(hehe, l, j);
    q_sort(hehe, j + 1, r);
}
int main()
{

    int n = 0;
    int c = 0;

    cin >> n >> c;
    vector<int>arr;
    int i = 0;
    int tem = 0;
    for (i = 0; i < n; i++)
    {
        scanf_s("%d", &tem);
        arr.push_back(tem);
    }
    q_sort(arr, 0, n - 1);
    // cout << n ;
    for (auto j : arr)
    {
        cout << j << ' ';
    }
    cout << arr[c] << endl;
    return 0;

}